package com.example;

import com.example.springboot.HelloWorldMain;
import com.example.springboot.service.TestService1;
import com.example.springboot.service.TestService2;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.BeansException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;


@SpringBootApplication
@MapperScan("com.example.springboot.mapper")
@EnableAsync
public class DemoApplication implements ApplicationContextAware {

    static ApplicationContext context = null;
    public static void main(String[] args) {

        SpringApplication.run(DemoApplication.class, args);
        /*TestService1 testService1 = (TestService1)context.getBean(TestService1.class);
        TestService2 testService2 = (TestService2)context.getBean(TestService2.class);
        HelloWorldMain helloWorldMain = (HelloWorldMain)context.getBean(HelloWorldMain.class);

        DemoApplication demoApplication = (DemoApplication)context.getBean(DemoApplication.class);
        testService1.test1();
        testService2.test2();*/


    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        context = applicationContext;
    }
}
